package com.fjp.heartguard.ui.question.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.fjp.heartguard.ui.question.fragment.CognitiveAssessment1Fragment
import com.fjp.heartguard.ui.question.fragment.CognitiveAssessment2Fragment
import com.fjp.heartguard.ui.question.fragment.CognitiveAssessment3Fragment
import com.fjp.heartguard.ui.question.fragment.RespondentUserinfoFragment

/**
 *Author:Mr'x
 *Time:2025/1/9
 *Description:
 */
class QuestionAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {
    private val fragments = arrayListOf<Fragment>(RespondentUserinfoFragment(), CognitiveAssessment1Fragment(), CognitiveAssessment2Fragment(), CognitiveAssessment3Fragment())

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getItem(position: Int): Fragment {
        return fragments[position]
    }

    fun addFragment(fragment: Fragment) {
        fragments.add(fragment)
        notifyDataSetChanged()

    }

    fun removeEndFragment() {
        fragments.removeAt(fragments.size - 1)
        notifyDataSetChanged()

    }
}